package com.invengo.base.utils;

import static com.invengo.library_db.entity.module_check.BookState.*;

import android.text.TextUtils;

import com.invengo.library_db.entity.module_check.BookBean;
import com.invengo.library_db.entity.module_check.BookState;

public class BookStateUtils {

    public static void handlerBookState(BookBean bean, String currentShelfCode, boolean isScan) {
        if (isScan)
            bean.setbLostBookFlag(0);
        if (bean.getState() == 9) {
            bean.setbLostBookFlag(0);
            if (isScan) {
                bean.setTip(LENG_OUT_IN_SHELF);
            } else {
                bean.setTip(LENG_OUT);
            }
        } else {
            if (TextUtils.isEmpty(bean.getShelfCode())) {//未上架图书
                bean.setTip(ERROR_NO_LISTING);
            } else if (bean.getShelfCode().equals(currentShelfCode)) {
                bean.setTip(isScan ? IN_SHELF : NEED_IN_SHELF);
            } else {
                bean.setTip(ERROR_OTHER_SHELF);
            }
        }
    }

    public static boolean isErrorBook(String state) {
        switch (state) {
            case ERROR_NO_LISTING:
            case ERROR_OTHER_SHELF:
                return true;
            default:
                return false;
        }
    }

    public static boolean isUnListingBook(@BookState String state) {
        switch (state) {
            case ERROR_NO_LISTING:
                return true;
            default:
                return false;
        }
    }

    public static boolean isInventoryErrorsBook(String state) {
        switch (state) {
            case ERROR_NO_LISTING:
            case ERROR_OTHER_SHELF:
                return true;
            default:
                return false;
        }
    }

    public static boolean isInventoryListingBook(@BookState String state) {
        switch (state) {
            case ERROR_NO_LISTING:
            case ERROR_OTHER_SHELF:
                return true;
            default:
                return false;
        }
    }
}
